<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Controllers\Controller;

use App\Org\Image;

class upfileController extends Controller
{
    public function index()
    {
    	return view('.upfile.index');
    }

    public function upfiles(Request $request)
    {
    	if($request->hasFile('pic')) {
    		$file = $request->file('pic');
    		if($file->isValid()) {
    			$ext = $file->getClientOriginalExtension();
    			$picname = time().rand(1,1000).'.'.$ext;
    			$file->move('./upfiles/',$picname);
    			if($file->getError() > 0) {
    				echo '上传失败';
    			}else{
    				echo '上传成功'.$picname;
    			}
    		}
    	}

    	$img = new Image();
    	$img->open('./upfiles/'.$picname);
    	$img->thumb(100,100)->save('./upfiles/s_'.$picname);
    }
}
